package com.gxar.quick.ar.server.base.common.enums.protocol;

import com.fasterxml.jackson.annotation.JsonCreator;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 协议尺寸单位
 *
 * @author zxh
 * @version 1.0
 * @created 2024/01/22.
 */
@Getter
public enum ArSizeUnitEnum {

    PX("px", "像素"),

    METER("meter", "米"),

    SPACE("space", "空间单位"),

    ;

    private final String name;
    private final String desc;

    ArSizeUnitEnum(String name, String desc) {
        this.name = name;
        this.desc = desc;
    }

    @JsonCreator
    public static ArSizeUnitEnum getByName(String name) {
        Optional<ArSizeUnitEnum> targetEnum = Arrays.stream(ArSizeUnitEnum.values()).filter(e -> e.getName().equals(name)).findFirst();
        return targetEnum.orElse(null);
    }
}
